package com.kfm.pm;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.SimpleFormatter;

public class Test01 {

    public static void main(String[] args) {


        int[] arr = new int[5];
        // 运行时异常
//        System.out.println(arr[5]);
//
//        Integer i = Integer.valueOf("abc");
////        stu.getAge();
//
        SimpleDateFormat simpleFormatter = new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date();
        String format = simpleFormatter.format(date);
        System.out.println(format);
        // 编译时异常 2023-09-01
        // 处理方法： 方法声明中加上 throws ParseException
        // try - catch  try{可能出现异常的代码} catch(异常类别 变量名) {如何处理异常}
        try {
            simpleFormatter.parse(format);
        } catch (ParseException e) {
            System.out.println(e.getMessage());
            System.out.println("你输入的字符串格式有问题！");
        }

//
        Pet pet = new Pet();
        // 向下转型
        if (pet instanceof Dog dog) {
            System.out.println("dog");
            System.out.println(dog);
        }
//        Dog dog = (Dog) pet;


    }
}
